package com.hl.sfzy.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.hl.sfzy.entity.Question;
import com.hl.sfzy.mapper.QuestionMapper;
import com.hl.sfzy.service.QuestionServue;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class QuestionServueImpl implements QuestionServue {
	@Autowired
	private QuestionMapper questionMapper;

	@Override
	public int add(Question question) {
		int add = questionMapper.Insert(question);
		return add;
	}

	@Override
	public int edit(Question question) {
		int edit = questionMapper.Update(question);
		return edit;
	}

	@Override
	public int remove(Integer questionId) {
		int remove = questionMapper.Delete(questionId);
		return remove;
	}

	@Override
	public int removeBatch(Integer[] questionIds) {
		int removeBatch = questionMapper.DeleteBatch(questionIds);
		return removeBatch;
	}

	@Override
	public PageInfo<Question> findByPage(int pageNum,int pageSize,Question question) {
		PageHelper.startPage(pageNum,pageSize);
		List<Question> questions = questionMapper.Select(question);
		PageInfo<Question> pageInfo = new PageInfo<>(questions);
		return pageInfo;
	}

	@Override
	public List<Question> find() {
		List<Question> questions = questionMapper.Select();
		return questions;
	}

	@Override
	public Question findById(Integer questionId) {
		Question question = questionMapper.SelectById(questionId);
		return question;
	}
}
